package com.ywger.service.init;

import com.ywger.dao.mapper.primary.EnsRegisterMapper;
import com.ywger.dao.mapper.primary.TxInfoMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @author chenmeng
 * @date 2021-07-15 21:54
 * @desc  项目初始化
 */
@Component
@Slf4j
public class AppInit implements CommandLineRunner {


    @Autowired
    private EnsRegisterMapper ensRegisterMapper;

    @Autowired
    private TxInfoMapper txInfoMapper;


    /**
     * @param args
     * @throws Exception
     * 出现异常系统无法启动
     */
    @Override
    public void run(String... args) throws Exception {
        //初始化mq
        if(0 == ensRegisterMapper.existTable()){
            ensRegisterMapper.createTable();
        }
        if(0 == txInfoMapper.existTable()){
            txInfoMapper.createTable();
        }

    }


}
